home *** CD-ROM | disk | FTP | other *** search
/ BBS Toolkit / BBS Toolkit.iso / windows / mrun211.zip / MRUN211F.WAS < prev    next >
Text File  |  1993-05-01  |  11KB  |  452 lines

  1. ;MailRun v2.11:  Part F, othercmds
  2. ;1992-1993 Gerald P. Sully, all rights reserved.
  3.  
  4. #comment
  5. **************************************************************************
  6. **************************************************************************
  7. * This file is a grab bag of routines for the following:
  8. * adding an item to Get or Send Mail; adding an item to send a
  9. * command; adding an item to execute a script; displaying the 
  10. * "About MailRun" dialog box.  The appropriate routine is 
  11. * selected with a FLAG.
  12. **************************************************************************
  13. **************************************************************************
  14. #endcomment
  15.  
  16. #define MRUN211F
  17.  
  18. #include "MRUN211.h"
  19.  
  20. string Command, ScriptName, ScriptList, MRunIcons, BBSChoice
  21. integer GetSendRadio, IconIndex
  22.  
  23.  
  24. #comment
  25. *********************************************************************
  26. * MAIN()
  27. * Calls checkchild(), addgetmail(), addsendcommand(), 
  28. * adddoscript(), showabout(), menudim()
  29. * Calls the appropriate function based on the value of
  30. * FLAGS.
  31. *********************************************************************
  32. #endcomment
  33.  
  34. proc main
  35. integer cmdstatus
  36.     menudim()
  37.     checkchild()
  38.     findfirst MailRun
  39.     MailRunTrunc = $FILENAME
  40.     cmdstatus = FLAGS & (AGM + CMD + SCR + ABT)
  41.     switch cmdstatus
  42.         case AGM
  43.             addgetmail()
  44.         endcase
  45.         case CMD
  46.             addsendcommand()
  47.         endcase
  48.         case SCR
  49.             adddoscript()
  50.         endcase
  51.         case ABT
  52.             showabout()
  53.         endcase
  54.     endswitch
  55. endproc
  56.  
  57.  
  58. #comment
  59. *********************************************************************
  60. * ADDGETMAIL()
  61. * Called by main()
  62. * Calls getlastitem(),
  63. * getmailbox(), gettaskstring(), makebbslist(),
  64. * insertitem(), interfaceon()
  65. * Adds a GetMail item to the mailrun.
  66. *********************************************************************
  67. #endcomment
  68.  
  69. proc addgetmail
  70. string GetMailString, GetSendMail, StatString, char
  71. integer dialogstatus, Perm, j
  72.     strextract BBSChoice TaskItem "`t" 3
  73.     strextract char TaskItem "`t" 4
  74.     atoi char j
  75.     makebbslist()
  76.     getmailbox()
  77.     statmsg ""
  78.     interfaceon()
  79.     while 1
  80.         dialogstatus = $DIALOG
  81.         switch dialogstatus
  82.             case 10
  83.                 ;User selected "Add"
  84.                 if GetSendRadio == 1
  85.                     GetSendMail = "GetMail"
  86.                     strfmt StatString "Added to %s:  `"Get QWK Packet`"" BBSChoice
  87.                 else
  88.                     GetSendMail = "SendMail"
  89.                     strfmt StatString "Added to %s:  `"Send REP Packet`"" BBSChoice
  90.                 endif
  91.                 Perm = 2 - PermRadio
  92.                 strfmt GetMailString "1,%d,%s" Perm GetSendMail
  93.                 ;Update MAILRUN.INI, task list
  94.                 j++
  95.                 insertitem(BBSChoice, j, GetMailString)
  96.                 TaskItem = gettaskstring(BBSChoice, j)
  97.                 statmsg StatString
  98.             endcase
  99.             case 11
  100.                 ;User selected "Done"
  101.                 exit
  102.             endcase
  103.             case 170
  104.                 ;User changed BBS with combobox
  105.                 j = getlastitem(BBSChoice)
  106.                 TaskItem = gettaskstring(BBSChoice, j)
  107.             endcase
  108.         endswitch
  109.     endwhile
  110. endproc
  111.  
  112.  
  113. #comment
  114. *********************************************************************
  115. * GETMAILBOX()
  116. * Called by addgetmail()
  117. * Displays the Get/Send Mail dialog box.
  118. *********************************************************************
  119. #endcomment
  120.  
  121. proc getmailbox
  122. PermRadio = 1
  123. GetSendRadio = 1
  124. destroydlg
  125. HelpPage = 8
  126. dialogbox 52 68 243 93 15 "Get/Send Mail" HELPID HelpPage
  127.    radiobutton 16 44 54 14 "Get Mail" GetSendRadio
  128.    radiobutton 16 63 54 14 "Send Mail" endgroup
  129.    radiobutton 94 44 54 14 "Permanent" PermRadio
  130.    radiobutton 94 63 54 14 "Temporary" endgroup
  131.    pushbutton 184 44 40 14 "&Add" normal default
  132.    pushbutton 184 63 40 14 "&Done" normal
  133.    text  52 12 68 8 right "Get/Send Mail for:"
  134.    combobox 124 10 67 41 BBSList BBSChoice sort
  135. enddialog
  136. endproc
  137.  
  138.  
  139. #comment
  140. *********************************************************************
  141. * ADDSENDCOMMAND()
  142. * Called by main()
  143. * Calls getlastitem(),
  144. * gettaskstring(), makebbslist(), interfaceon(),
  145. * sendcommandbox(), insertitem()
  146. * Adds a "SendCommand" item to the mailrun.  A command
  147. * string may contain multiple command lines separated by
  148. * verticle bars.  Successive command lines will be sent
  149. * when the terminal screen is quiet for 15 seconds.
  150. *********************************************************************
  151. #endcomment
  152.  
  153. proc addsendcommand
  154. string CommandString, StatString, char
  155. integer dialogstatus, Perm, j
  156.     strextract BBSChoice TaskItem "`t" 3
  157.     strextract char TaskItem "`t" 4
  158.     atoi char j
  159.     makebbslist()
  160.     sendcommandbox()
  161.     statmsg ""
  162.     interfaceon()
  163.     while 1
  164.         dialogstatus = $DIALOG
  165.         switch dialogstatus
  166.             case 10
  167.                 ;User selected "Add"
  168.                 Perm = 2 - PermRadio
  169.                 strfmt CommandString "1,%d,SendCommand,%s" Perm Command
  170.                 strfmt StatString "Added to %s:  `"Send Command:  %s`"" \
  171.                     BBSChoice Command
  172.                 j++
  173.                 insertitem(BBSChoice, j, CommandString)
  174.                 TaskItem = gettaskstring(BBSChoice, j)
  175.                 statmsg StatString
  176.             endcase
  177.             case 11
  178.                 ;User selected "Done"
  179.                 exit
  180.             endcase
  181.             case 170
  182.                 ;User changed BBS with the combobox
  183.                 j = getlastitem(BBSChoice)
  184.                 TaskItem = gettaskstring(BBSChoice, j)
  185.             endcase
  186.         endswitch
  187.     endwhile
  188. endproc
  189.  
  190.  
  191. #comment
  192. *********************************************************************
  193. * SENDCOMMANDBOX()
  194. * Called by addsendcommand()
  195. * Displays the Send Command dialog box.
  196. *********************************************************************
  197. #endcomment
  198.  
  199. proc sendcommandbox
  200. PermRadio = 2
  201. Command = ""
  202. destroydlg
  203. HelpPage = 11
  204. dialogbox 92 63 196 124 15 "Send Command" HELPID HelpPage
  205.    text  8 39 42 8 right "Command:"
  206.    editbox 54 37 124 11 Command
  207.    radiobutton 32 85 59 11 "Permanent" PermRadio
  208.    radiobutton 32 101 59 11 "Temporary" endgroup
  209.    pushbutton 129 77 40 14 "&Add" normal default
  210.    pushbutton 129 97 40 14 "&Done" normal
  211.    text  30 15 68 8 right "Send Command to:"
  212.    combobox 102 13 65 42 BBSList BBSChoice sort
  213.    text  54 51 97 8 left "Use a vertical bar (`"|`") to"
  214.    text  54 61 97 8 left "separate multiple commands."
  215. enddialog
  216. endproc
  217.  
  218.  
  219. #comment
  220. *********************************************************************
  221. * ADDDOSCRIPT()
  222. * Called by main()
  223. * Calls getlastitem(),
  224. * makebbslist(), makescriptlist(), interfaceon(),
  225. * gettaskstring(), scriptbox(), insertitem()
  226. * Adds a SendScript Item to the mailrun.
  227. *********************************************************************
  228. #endcomment
  229.  
  230. proc adddoscript
  231. string ScriptString, StatString, char
  232. integer dialogstatus, Perm, j
  233.     strextract BBSChoice TaskItem "`t" 3
  234.     strextract char TaskItem "`t" 4
  235.     atoi char j
  236.     makebbslist()
  237.     makescriptlist()
  238.     scriptbox()
  239.     statmsg ""
  240.     interfaceon()
  241.     while dialogstatus != 1
  242.         dialogstatus = $DIALOG
  243.         switch dialogstatus
  244.             case 10
  245.                 ;User chose "Add"
  246.                 Perm = 2 - PermRadio
  247.                 strupr ScriptName
  248.                 strfmt ScriptString "1,%d,SendScript,%s" Perm ScriptName
  249.                 strfmt StatString "Added to %s:  `"Execute Script:  %s`"" \
  250.                     BBSChoice ScriptName
  251.                 j++
  252.                 insertitem(BBSChoice, j, ScriptString)
  253.                 TaskItem = gettaskstring(BBSChoice, j)
  254.                 statmsg StatString
  255.             endcase
  256.             case 11
  257.                 ;User selected "Done"
  258.                 exit
  259.             endcase
  260.             case 170
  261.                 ;User changed BBS with the combobox
  262.                 j = getlastitem(BBSChoice)
  263.                 TaskItem = gettaskstring(BBSChoice, j)
  264.             endcase
  265.         endswitch
  266.     endwhile
  267. endproc
  268.  
  269.  
  270. #comment
  271. *********************************************************************
  272. * MAKESCRIPTLIST()
  273. * Called by adddoscript()
  274. * Calls openfile(), makefullname()
  275. * Creates a list of scripts for display in the scriptbox()
  276. * dialog box script fcombobox.
  277. *********************************************************************
  278. #endcomment
  279.  
  280. proc makescriptlist
  281. string ScriptSpec, NextScript, ScriptLine
  282.     ScriptName = ""
  283.     ScriptList = makefullname(TempDir, "SCRIPTS.TMP")
  284.     openfile(ScriptFile, ScriptList, _CREATE, _TEXT)
  285.     ScriptSpec = makefullname(MailRunDir, "*.WA?")
  286.     findfirst ScriptSpec
  287.     ;Loop through all files in the directory
  288.     while FOUND
  289.         NextScript = $FNAME
  290.         strlwr NextScript
  291.         switch NextScript
  292.             case "MRUN211"
  293.             case "MRUN211A"
  294.             case "MRUN211B"
  295.             case "MRUN211C"
  296.             case "MRUN211D"
  297.             case "MRUN211E"
  298.             case "MRUN211F"
  299.             case "MRUN211G"
  300.             case "ARRAY"
  301.             case "HOST"
  302.             case "HOSTUTIL"
  303.             case "USER"
  304.             case "SUBS"
  305.             case "MAIL"
  306.             endcase
  307.             default
  308.                 rewind ScriptFile
  309.                 fgets ScriptFile ScriptLine
  310.                 while not NULLSTR ScriptLine
  311.                     if strcmp ScriptLine NextScript
  312.                         exitswitch
  313.                     endif
  314.                     fgets ScriptFile ScriptLine
  315.                 endwhile
  316.                 fputs ScriptFile NextScript
  317.                 if NULLSTR ScriptName
  318.                     ScriptName = NextScript
  319.                 endif
  320.             endcase
  321.         endswitch
  322.         findnext
  323.     endwhile
  324.     fclose ScriptFile
  325. endproc
  326.  
  327.  
  328. #comment
  329. *********************************************************************
  330. * SCRIPTBOX()
  331. * Called by adddoscript()
  332. * Displays the Execute Script dialog box.
  333. *********************************************************************
  334. #endcomment
  335.  
  336. proc scriptbox
  337. PermRadio = 2
  338. destroydlg
  339. ScriptName = "terminal"
  340. HelpPage = 12
  341. dialogbox 92 60 180 135 15 "Execute Script" HELPID HelpPage
  342.    text  14 36 64 8 right "Available Scripts:"
  343.    fcombobox 82 34 76 42 ScriptList ScriptName sort
  344.    text  20 54 136 22 left "WARNING:  Scripts must not alter \
  345. global variables s0-s9 and i0-i9!!!"
  346.    radiobutton 17 85 62 14 "Permanent" PermRadio
  347.    radiobutton 17 107 62 14 "Temporary" endgroup
  348.    pushbutton 114 85 40 14 "&Add" normal default
  349.    pushbutton 114 107 40 14 "&Done" normal
  350.    text  14 11 64 8 right "Execute Script at:"
  351.    combobox 82 9 76 42 BBSList BBSChoice sort
  352. enddialog
  353. endproc
  354.  
  355.  
  356. #comment
  357. *********************************************************************
  358. * SHOWABOUT()
  359. * Called by main()
  360. * Calls aboutbox()
  361. * Displays the About MailRun dialog box.
  362. *********************************************************************
  363. #endcomment
  364.  
  365. proc showabout
  366. integer dialogstatus
  367.     statmsg ""
  368.     aboutbox()
  369.     dialogstatus = $DIALOG
  370.     while dialogstatus != 1
  371.         dialogstatus = $DIALOG
  372.     endwhile
  373.     exit
  374. endproc
  375.  
  376.  
  377. #comment
  378. *********************************************************************
  379. * ABOUTBOX()
  380. * Called by showabout()
  381. * Calls makefullname()
  382. * Displays the About MailRun dialog box.
  383. *********************************************************************
  384. #endcomment
  385.  
  386. proc aboutbox
  387. destroydlg
  388. HelpPage = 1
  389. MRunIcons = makefullname(MailRunDir, "MRUNICON.DLL")
  390. IconIndex = 17
  391. dialogbox 55 55 220 151 15 "About MailRun" HELPID HelpPage
  392.    text  42 14 136 27 center "MailRun`r`nVersion 2.11`r`n\
  393. Copyright ⌐ 1992-1993 Gerald P. Sully"
  394.    text  20 48 180 28 left "If you use MailRun with any regularity, \
  395. ease your aching conscience by helping out a starving author.`r`n\
  396. Send $15 to:"
  397.    icon 160 82 MRunIcons IconIndex
  398.    text  20 80 120 44 left "Jerry Sully`r`n841 Solano Ave. #2`r`n\
  399. Albany, CA  94706`r`n`r`nThank you for your support!"
  400.    pushbutton 20 128 180 14 "I promise I'll send $15 as soon as I \
  401. can afford it!" cancel
  402. enddialog
  403. endproc
  404.